var app = getApp();
var config = require('../../../config.js');
var util = require('../../../js/common.util.js');
Page({
  data: {
    id:'',
    detailInfo:{}
  },
  onLoad: function (options) {
    this.loadDetail(options.id)
    this.setData({
      id:options.id
    })
  },
  onShareAppMessage: function () {

  },
  addStatus(){
    wx.navigateTo({
      url: '/page/BusinessCenter/modifyState/index?id='+this.data.id
    })
  },
  loadDetail(id){
    let self = this
    app.request({
      url: 'api/wechat/GetBusinessById',
      method: "GET",
      data: {
        id:id
      },
      success: function (res) {
        console.log(res)
        if(res != null &&res.data != null && res.data.info != null){
          if(res.data.info.passTime != null){
            res.data.info.passTime = util.formatTime(res.data.info.passTime)
          }
          res.data.info.createTime = util.formatTime(res.data.info.createTime)
          if(res.data.info.rejectTime != null){
            res.data.info.rejectTime = util.formatTime(res.data.info.rejectTime)
          }
          if (res.data.info.awaitTime != null) {
            res.data.info.awaitTime = util.formatTime(res.data.info.awaitTime)
          }
          if (res.data.info.confirmAwaitTime != null) {
            res.data.info.confirmAwaitTime = util.formatTime(res.data.info.confirmAwaitTime)
          }
          if (res.data.info.signTime != null) {
            res.data.info.signTime = util.formatTime(res.data.info.signTime)
          }
          if (res.data.info.confirmSignTime != null) {
            res.data.info.confirmSignTime = util.formatTime(res.data.info.confirmSignTime)
          }
          if (res.data.info.moneyTime != null) {
            res.data.info.moneyTime = util.formatTime(res.data.info.moneyTime)
          }
          var strs = res.data.info.productImg
          var imgList = ''
          var img = ''
          if(strs != null && strs != ''){
            imgList = strs.split(',')
            if (imgList != null && imgList.length > 0){
              img = imgList[0]
            }
          }
          res.data.info.productImg = config.imgPath + img
          console.log(res.data.info.productImg)
          self.setData({
            detailInfo:res.data.info,
          })
        }
      }
    })
  }
})